package com.carleasoft.mps.adu.business.user.controller;

import java.text.ParseException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.carleasoft.mps.adu.business.user.bean.entity.MAuthorityStaggerHolidays;
import com.carleasoft.mps.adu.business.user.bean.po.MAuthorityStaggerHolidaysPo;
import com.carleasoft.mps.adu.business.user.bean.po.MAuthorityUserDynamicPo;
import com.carleasoft.mps.adu.business.user.bean.vo.MAuthorityDeptCountVo;
import com.carleasoft.mps.adu.business.user.bean.vo.MAuthorityStaggerHolidaysVo;
import com.carleasoft.mps.adu.business.user.bean.vo.MAuthorityUserDynamicVo;
import com.carleasoft.mps.core.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.carleasoft.mps.adu.business.user.service.IMAuthorityStaggerHolidaysService;
import org.springframework.web.multipart.MultipartFile;

/**
 * 人员轮休Controller
 * 
 * @author yiSl
 * @date 2024-04-12
 */
@RestController
@RequestMapping("/userStaggerHolidays")
public class MAuthorityStaggerHolidaysController
{
    @Autowired
    private IMAuthorityStaggerHolidaysService mAuthorityStaggerHolidaysService;

    /**
     * 查询人员轮休列表
     */
    @PostMapping("/list")
    public R list(@RequestBody MAuthorityStaggerHolidaysPo mAuthorityStaggerHolidaysPo)
    {
        Page<MAuthorityStaggerHolidaysVo> list = mAuthorityStaggerHolidaysService.selectMAuthorityStaggerHolidaysList(new Page(mAuthorityStaggerHolidaysPo.getCurrent(), mAuthorityStaggerHolidaysPo.getSize()),mAuthorityStaggerHolidaysPo);
        return R.ok(list);
    }

    /**
     * 导入人员轮休
     * @param file
     * @return
     */
    @PostMapping("/importUserStaggerHolidaysExcel")
    public R importUserDynamicExcel(@RequestPart("file") MultipartFile file) {
        boolean isOk = mAuthorityStaggerHolidaysService.userStaggerHolidaysExcel(file);
        return R.ok(isOk);
    }


    /**
     * 人员轮休导出
     * @param startTime
     * @param response
     * @return
     */
    @PostMapping("/exportUserStaggerHolidaysExcel")
    public R<Boolean> export(HttpServletResponse response,@RequestPart("startTime") String startTime) throws ParseException {
        return R.ok(mAuthorityStaggerHolidaysService.export(response,startTime));
    }

    /**
     * 获取人员轮休详细信息
     */
    @PostMapping(value = "/getById")
    public R getInfo(@RequestBody MAuthorityStaggerHolidaysPo mAuthorityStaggerHolidaysPo)
    {
        return R.ok(mAuthorityStaggerHolidaysService.selectMAuthorityStaggerHolidaysById(mAuthorityStaggerHolidaysPo.getId()));
    }

    /**
     * 根据部门CODE分组求和轮休总数
     */
    @PostMapping("/deptCount")
    public R deptCount()
    {
        List<MAuthorityDeptCountVo> list = mAuthorityStaggerHolidaysService.selectMAuthorityDeptCountByDeptCode();
        return R.ok(list);
    }

    /**
     * 新增人员轮休
     */
    @PostMapping("/add")
    public R add(@RequestBody MAuthorityStaggerHolidays mAuthorityStaggerHolidays)
    {
        return R.ok(mAuthorityStaggerHolidaysService.insertMAuthorityStaggerHolidays(mAuthorityStaggerHolidays));
    }

    /**
     * 修改人员轮休
     */
    @PostMapping("/update")
    public R edit(@RequestBody MAuthorityStaggerHolidays mAuthorityStaggerHolidays)
    {
        return R.ok(mAuthorityStaggerHolidaysService.updateMAuthorityStaggerHolidays(mAuthorityStaggerHolidays));
    }

    /**
     * 删除人员轮休
     */
	@PostMapping("/delete")
    public R remove(@RequestBody MAuthorityStaggerHolidays mAuthorityStaggerHolidays)
    {
        return R.ok(mAuthorityStaggerHolidaysService.deleteMAuthorityStaggerHolidaysById(mAuthorityStaggerHolidays.getId()));
    }
}
